{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "893a37cb",
   "metadata": {},
   "outputs": [],
   "source": [
    "LONG_TEST=\"No\""
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "0666783d",
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "True"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "import os\n",
    "import chipwhisperer as cw\n",
    "import time\n",
    "import pytest\n",
    "test_args = [\"pytest\", \"-v\", \"-rs\", \"../../tests/test_husky.py\", \"-k\", \"not trace\"]\n",
    "if LONG_TEST != \"No\":\n",
    "    test_args.append(\"--fulltest\")\n",
    "scope = cw.scope()\n",
    "env = dict(os.environ)\n",
    "env[\"HUSKY_HW_LOC\"] = str(scope._getNAEUSB().hw_location())\n",
    "env[\"HUSKY_TARGET_PLATFORM\"] = \"sam4s\"\n",
    "#target = cw.target(scope)\n",
    "scope.default_setup()\n",
    "time.sleep(0.25)\n",
    "#cw.naeusb_logger.setLevel(cw.logging.DEBUG)\n",
    "cw.program_target(scope, cw.programmers.SAM4SProgrammer, \"../../firmware/mcu/simpleserial-trace/simpleserial-trace-CW308_SAM4S.hex\")\n",
    "scope.dis()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "f937c0de",
   "metadata": {},
   "outputs": [],
   "source": [
    "import subprocess\n",
    "result = subprocess.run(test_args, capture_output=True, env=env)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "d43cdbab",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "============================= test session starts =============================\n",
      "platform win32 -- Python 3.10.4, pytest-7.3.1, pluggy-1.0.0 -- C:\\Users\\adewa\\.pyenv\\pyenv-win\\versions\\3.10.4\\python.exe\n",
      "cachedir: .pytest_cache\n",
      "rootdir: C:\\Users\\adewa\\code\\chipwhisperer\\tests\n",
      "configfile: pytest.ini\n",
      "plugins: anyio-3.6.2\n",
      "collecting ... \n",
      "\n",
      "\n",
      "\n",
      "**************************************************************************************\n",
      "* IMPORTANT NOTE:                                                                    *\n",
      "* This script is intended for basic regression testing of Husky during               *\n",
      "* development. If you are having issues connecting to your Husky or target           *\n",
      "* device, running this script is unlikely to provide you with useful information.    *\n",
      "* Instead, seek assistance on forum.newae.com or discord by providing details of     *\n",
      "* your setup (including the target), and the full error log from your Jupyter        *\n",
      "* notebook.                                                                          *\n",
      "*                                                                                    *\n",
      "* While this test can be run on a stand-alone Husky, some of the tests require a     *\n",
      "* target with a specific FW (which supports segmenting and trace):                   *\n",
      "* simpleserial-trace.                                                                *\n",
      "* The expected .hex file and this script should be updated together.                 *\n",
      "* If this FW is recompiled, the trace.set_isync_matches() call will have to be       *\n",
      "* modified with updated instruction addresses.                                       *\n",
      "**************************************************************************************\n",
      "\n",
      "\n",
      "hw_loc added (1, 7)\n",
      "Husky target platform sam4s\n",
      "collected 146 items / 6 deselected / 140 selected\n",
      "\n",
      "..\\..\\tests\\test_husky.py::test_fpga_version PASSED\n",
      "..\\..\\tests\\test_husky.py::test_fw_version PASSED\n",
      "..\\..\\tests\\test_husky.py::test_reg_rw[16-4-1000-SAMPLES] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_reg_rw[4-8-1000-ECHO] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[10-0-internal-20000000.0-True-1-8-False-1-0-1-quick] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[131070-0-internal-20000000.0-True-1-8-False-1-0-1-maxsamples8_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[131070-0-internal-20000000.0-True-1-12-False-1-0-1-maxsamples12] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[300-0-internal-20000000.0-True-1-8-False-10-1000-1-evensegments8_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[50-0-internal-20000000.0-True-1-8-False-100-100-1-oddsegments8_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[300-0-internal-20000000.0-True-1-12-False-10-1000-1-evensegments12_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[50-0-internal-20000000.0-True-1-12-False-100-100-1-oddsegments12] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[300-30-internal-20000000.0-True-1-12-False-20-500-1-presamplesegments] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[131070-0-internal-10000000.0-True-1-12-False-1-0-1-slow_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[131070-0-internal-80000000.0-True-1-12-False-1-0-1-fast_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[131070-0-internal-200000000.0-True-1-12-False-1-0-10-fastest] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[131070-0-internal-250000000.0-True-1-12-False-1-0-1-overclocked] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[131070-0-internal-5000000.0-True-4-12-False-1-0-1-4xslow_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[131070-0-internal-50000000.0-True-4-12-False-1-0-1-4xfast] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[131070-0-ADCramp-20000000.0-True-1-12-False-1-0-1-ADCslow] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[131070-0-ADCramp-200000000.0-True-1-12-False-1-0-10-ADCfast_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[131070-0-ADCramp-50000000.0-True-4-12-False-1-0-1-ADC4xfast] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[131070-0-ADCramp-250000000.0-True-1-12-False-1-0-1-ADCoverclocked] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[8192-0-ADCramp-10000000.0-True-1-12-False-12-10000-1-ADClongsegments_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[64-0-ADCramp-200000000.0-True-1-12-False-1536-400-10-ADCfastsegments] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[300-30-ADCramp-200000000.0-True-1-12-False-327-400-10-ADCfastsegmentspresamples] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[300-30-ADCramp-250000000.0-True-1-12-False-327-400-1-ADCoverclockedsegmentspresamples] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[131070-0-ADCalt-20000000.0-True-1-12-False-1-0-10-ADCaltslow_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[131070-0-ADCalt-200000000.0-True-1-12-False-1-0-10-ADCaltfast] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[131070-0-ADCalt-250000000.0-True-1-12-False-1-0-1-ADCaltoverclocked_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[500-0-internal-20000000.0-False-1-12-False-1-0-1-slowreads] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_internal_ramp[131070-0-internal-20000000.0-False-1-12-False-1-0-1-maxslowreads_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_adc_freq_sweep[30-15-48000000.0-56000000.0-1000000.0-internal-True-1-12-False-327-100-50-int_segmentspresamples_slow] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_adc_freq_sweep[30-15-100000000.0-108000000.0-1000000.0-internal-True-1-12-False-327-100-50-int_segmentspresamples_fast] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_adc_freq_sweep[30-15-10000000.0-210000000.0-5000000.0-internal-True-1-12-False-327-100-2-int_segmentspresamples_full] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_adc_freq_sweep[300-30-48000000.0-56000000.0-1000000.0-internal-True-1-12-False-327-400-10-int_segmentspresamples_long] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_adc_freq_sweep[8192-0-10000000.0-210000000.0-5000000.0-ADCramp-True-1-12-False-12-100000-2-longsegments] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_adc_freq_sweep[64-0-10000000.0-210000000.0-5000000.0-ADCramp-True-1-12-False-1536-400-2-shortsegments] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_offset[10000000.0-0.1-0-40-] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_glitch_offset[10000000.0-0.1-400-40-SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_offset[10000000.0-0.1-800-40-SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_offset[10000000.0-0.1-1600-40-] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_glitch_offset[20000000.0-0.2-200-20-] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_glitch_offset[20000000.0-0.2-500-20-SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_offset[100000000.0-0.6-0-5-] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_glitch_offset[100000000.0-0.6-50-5-SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_offset[100000000.0-0.6-100-5-] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_glitch_width[0-40-] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_glitch_width[400-40-] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_glitch_width[800-40-] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_glitch_width[1600-40-] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_sweep_width[10000000.0-0-40-2-] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_sweep_width[10000000.0-600-40-2-SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_sweep_width[10000000.0-1200-40-2-] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_sweep_width[10000000.0--1200-40-2-] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_sweep_width[10000000.0-0-20-4-SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_sweep_width[50000000.0-200-8-10-] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_sweep_width[100000000.0-400-4-20-] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_sweep_width[200000000.0-600-2-40-SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_missing_glitch_sweep_offset[10000000.0-600000000.0-100-1000-1-5-20-1-] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_missing_glitch_sweep_offset[10000000.0-600000000.0-100-1000-10-5-20-1-] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_missing_glitch_sweep_offset[15000000.0-600000000.0-100-1000-10-5-20-1-] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_missing_glitch_sweep_offset[25000000.0-600000000.0-100-1000-10-5-10-1-] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_sweep_offset[10000000.0-200-35-2-] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_sweep_offset[10000000.0--200-35-2-] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_sweep_offset[10000000.0-1000-35-2-] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_sweep_offset[10000000.0--1000-35-2-] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_sweep_offset[10000000.0-3000-35-2-] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_sweep_offset[10000000.0--3000-35-2-] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_sweep_offset[10000000.0-500-30-2-] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_sweep_offset[10000000.0-500-20-2-] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_sweep_offset[50000000.0-100-8-10-may_fail] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_sweep_offset[50000000.0-200-8-10-may_fail] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_sweep_offset[100000000.0-100-4-20-may_fail] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_sweep_offset[100000000.0-150-4-20-may_fail] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_sweep_offset[125000000.0-50-4-30-may_fail] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_sweep_offset[125000000.0-70-4-30-may_fail] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_doubles[10000000.0-600000000.0-1-20-1-] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_doubles[10000000.0-1200000000.0-1-20-1-] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_doubles[10000000.0-600000000.0-2-20-1-] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_doubles[50000000.0-600000000.0-1-8-1-] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_doubles[100000000.0-600000000.0-1-4-1-] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_output_doubles[100000000.0-600000000.0-2-4-1-] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_target_internal_ramp[200-0-internal-20000000.0-True-1-8-False-65536-True-1-0-quick] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_target_internal_ramp[131070-0-internal-15000000.0-True-1-12-False-65536-True-1-0-maxsamples12] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_target_internal_ramp[200000-0-internal-20000000.0-True-1-8-True-65536-True-1-0-quickstream8] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_target_internal_ramp[2000000-0-internal-16000000.0-True-1-12-True-65536-True-1-0-longstream12_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_target_internal_ramp[6000000-0-internal-16000000.0-True-1-12-True-65536-False-1-0-vlongstream12_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_target_internal_ramp[500000-0-internal-20000000.0-True-1-12-True-16384-True-1-0-over_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_target_internal_ramp[3000000-0-internal-24000000.0-True-1-12-True-65536-False-1-0-overflow_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_target_internal_ramp[200000-0-internal-15000000.0-True-1-12-True-65536-True-1-0-postfail_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_target_internal_ramp[2000-0-internal-10000000.0-True-1-8-False-65536-True-1-0-back2nostream_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_target_internal_ramp[500000-0-internal-12000000.0-False-1-12-True-65536-True-1-0-slowreads1_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_target_internal_ramp[2000000-0-internal-10000000.0-False-1-12-True-65536-True-1-0-slowreads2_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_segments[0-0-90-False-7370000.0-4-False-20-0-segments_trigger_no_offset] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_segments[0-10-90-False-7370000.0-4-False-20-0-segments_trigger_no_offset_presamp] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_segments[10-0-90-False-7370000.0-4-False-20-0-segments_trigger_offset10_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_segments[50-0-90-False-7370000.0-4-False-20-0-segments_trigger_offset50_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_segments[50-20-90-False-7370000.0-4-False-20-0-segments_trigger_offset50_presamp] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_segments[0-0-100-True-7370000.0-4-False-2000-0-segments_trigger_stream_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_segments[0-0-90-False-7370000.0-4-True-20-32500-segments_counter_no_offset] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_segments[0-30-90-False-7370000.0-4-True-20-32500-segments_counter_no_offset_presamp_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_segments[10-0-90-False-7370000.0-4-True-20-32500-segments_counter_offset10_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_segments[50-0-90-False-7370000.0-4-True-20-32500-segments_counter_offset50_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_segments[50-40-90-False-7370000.0-4-True-20-32500-segments_counter_offset50_presamp] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_sad_trigger[10000000.0-1-8-200-0-50-8bits] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_sad_trigger[10000000.0-1-12-200-0-50-12bits] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_sad_trigger[10000000.0-1-8-200-0-10-8bits_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_sad_trigger[10000000.0-10-8-200-0-50-fast_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_sad_trigger[10000000.0-18-8-200-0-50-faster_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_sad_trigger[10000000.0-20-8-200-0-50-fastest] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_sad_trigger[10000000.0-25-8-200-0-50-overclocked_SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_multiple_sad_trigger[10000000.0-4-8-0-100-10-2700-20-regular] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_multiple_sad_trigger[10000000.0-4-8-1-100-10-2700-20-half] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_multiple_sad_trigger[10000000.0-20-8-0-150-10-13500-20-fast] FAILED\n",
      "..\\..\\tests\\test_husky.py::test_uart_trigger[10000000.0-tio1-r7DF7-None-8-10-tio1_10M] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_uart_trigger[10000000.0-tio1-r7DF7xxx-mask1-5-10-tio1_10M] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_uart_trigger[10000000.0-tio1-r7Dxxxxx-mask2-3-10-tio1_10M] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_uart_trigger[10000000.0-tio2-p000000-None-8-10-tio2_10M] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_uart_trigger[20000000.0-tio1-r7DF7-None-8-10-tio1_20M] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_uart_trigger[20000000.0-tio2-p000000-None-8-10-tio2_20M] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_adc_trigger[1-0.9-12-3-] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_adc_trigger[10-0.9-12-3-] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_adc_trigger[5-0.9-8-3-SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_adc_trigger[5-0.5-8-3-] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_adc_trigger[1-0.5-12-3-SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_adc_trigger[10-0.5-12-3-SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_edge_trigger[tio1-2-4-True-3-] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_edge_trigger[tio1-4-4-True-3-SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_edge_trigger[tio1-100-4-False-50-] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_edge_trigger[tio2-3-4-True-10-SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_edge_trigger[tio2-5-4-True-10-] PASSED\n",
      "..\\..\\tests\\test_husky.py::test_edge_trigger[tio2-50-4-False-50-SLOW] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_userio_edge_triggers[pins0-260-3-] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_modes SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_trigger[basic-pattern0-100-basic_glitch_arm_active] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_trigger[basic-pattern1-100-basic_glitch_arm_inactive] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_trigger[edge_counter-pattern2-100-edge_glitch_arm_inactive] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_glitch_trigger[edge_counter-pattern3-100-edge_glitch_arm_active] SKIPPED (use --fulltest to run)\n",
      "..\\..\\tests\\test_husky.py::test_xadc PASSED\n",
      "..\\..\\tests\\test_husky.py::test_finish PASSED\n",
      "\n",
      "================================== FAILURES ===================================\n",
      "______ test_multiple_sad_trigger[10000000.0-20-8-0-150-10-13500-20-fast] ______\n",
      "..\\..\\tests\\test_husky.py:1336: in test_multiple_sad_trigger\n",
      "    assert scope.SAD.num_triggers_seen == scope.adc.segments\n",
      "E   AssertionError: assert 24 == 10\n",
      "E    +  where 24 = threshold            = 150\n",
      "reference            = [129, 129, 130, 130, 130, 130, 131, 131, 128, 127, 128, 129, 128, 128, 129, 130, 129, 129, 129, 129, 129, 129, 130, 130, 130, 130, 131, 131, 129, 128, 129, 130, 129, 129, 130, 130, 130, 130, 130, 130, 130, 130, 130, 131, 130, 131, 131, 131, 129, 126, 123, 120, 119, 117, 113, 114, 116, 115, 114, 116, 117, 117, 118, 119, 120, 120, 121, 123, 121, 118, 116, 114, 112, 111, 108, 108, 110, 110, 110, 112, 113, 114, 115, 116, 118, 119, 120, 121, 119, 119, 121, 122, 122, 122, 124, 125, 124, 125, 126, 126, 126, 126, 127, 128, 128, 129, 130, 129, 127, 124, 121, 118, 117, 115, 112, 112, 114, 114, 113, 114, 116, 117, 117, 119, 120, 120, 122, 123]\n",
      "sad_reference_length = 128\n",
      "half_pattern         = False\n",
      "multiple_triggers    = True\n",
      "num_triggers_seen    = 24\n",
      ".num_triggers_seen\n",
      "E    +    where threshold            = 150\n",
      "reference            = [129, 129, 130, 130, 130, 130, 131, 131, 128, 127, 128, 129, 128, 128, 129, 130, 129, 129, 129, 129, 129, 129, 130, 130, 130, 130, 131, 131, 129, 128, 129, 130, 129, 129, 130, 130, 130, 130, 130, 130, 130, 130, 130, 131, 130, 131, 131, 131, 129, 126, 123, 120, 119, 117, 113, 114, 116, 115, 114, 116, 117, 117, 118, 119, 120, 120, 121, 123, 121, 118, 116, 114, 112, 111, 108, 108, 110, 110, 110, 112, 113, 114, 115, 116, 118, 119, 120, 121, 119, 119, 121, 122, 122, 122, 124, 125, 124, 125, 126, 126, 126, 126, 127, 128, 128, 129, 130, 129, 127, 124, 121, 118, 117, 115, 112, 112, 114, 114, 113, 114, 116, 117, 117, 119, 120, 120, 122, 123]\n",
      "sad_reference_length = 128\n",
      "half_pattern         = False\n",
      "multiple_triggers    = True\n",
      "num_triggers_seen    = 24\n",
      " = cwhusky Device\n",
      "sn             = 50203120374a38503230343136303038\n",
      "fpga_buildtime = 4/5/2023, 21:22\n",
      "fw_version = \n",
      "    major = 1\n",
      "    minor = 5\n",
      "    debug = 0\n",
      "gain = \n",
      "    mode = low\n",
      "    gain = 59\n",
      "    db   = 12.064220183486238\n",
      "adc = \n",
      "    state                    = False\n",
      "    basic_mode               = rising_edge\n",
      "    timeout                  = 3\n",
      "    offset                   = 0\n",
      "    presamples               = 137\n",
      "    samples                  = 255\n",
      "    decimate                 = 1\n",
      "    trig_count               = 24\n",
      "    stream_mode              = False\n",
      "    test_mode                = False\n",
      "    bits_per_sample          = 8\n",
      "    segments                 = 10\n",
      "    segment_cycles           = 32500\n",
      "    segment_cycle_counter_en = False\n",
      "    clip_errors_disabled     = False\n",
      "    lo_gain_errors_disabled  = True\n",
      "    errors                   = False\n",
      "clock = \n",
      "    clkgen_src             = system\n",
      "    clkgen_freq            = 10000000.0\n",
      "    adc_mul                = 20\n",
      "    adc_freq               = 200000000.0\n",
      "    freq_ctr               = 57\n",
      "    freq_ctr_src           = extclk\n",
      "    clkgen_locked          = True\n",
      "    adc_phase              = 0\n",
      "    extclk_monitor_enabled = False\n",
      "    extclk_error           = False\n",
      "    extclk_tolerance       = 102.996826171875\n",
      "trigger = \n",
      "    module = SAD\n",
      "io = \n",
      "    tio1            = serial_rx\n",
      "    tio2            = serial_tx\n",
      "    tio3            = high_z\n",
      "    tio4            = high_z\n",
      "    pdid            = high_z\n",
      "    pdic            = high_z\n",
      "    nrst            = high_z\n",
      "    glitch_hp       = False\n",
      "    glitch_lp       = False\n",
      "    extclk_src      = hs1\n",
      "    hs2             = clkgen\n",
      "    target_pwr      = True\n",
      "    tio_states      = (1, 1, 1, 0)\n",
      "    cdc_settings    = bytearray(b'\\x00\\x00\\x00\\x00')\n",
      "    aux_io_mcx      = high_z\n",
      "    glitch_trig_mcx = trigger\n",
      "glitch = \n",
      "    enabled           = False\n",
      "    mmcm_locked       = False\n",
      "    num_glitches      = 1\n",
      "    clk_src           = pll\n",
      "    width             = 328\n",
      "    offset            = 400\n",
      "    trigger_src       = manual\n",
      "    arm_timing        = after_scope\n",
      "    ext_offset        = 0\n",
      "    repeat            = 1\n",
      "    output            = glitch_only\n",
      "    phase_shift_steps = 3360\n",
      "ADS4128 = \n",
      "    mode      = normal\n",
      "    low_speed = True\n",
      "    hi_perf   = 2\n",
      "LA = \n",
      "    present                  = True\n",
      "    enabled                  = False\n",
      "    clkgen_enabled           = True\n",
      "    locked                   = True\n",
      "    clk_source               = pll\n",
      "    trigger_source           = glitch_trigger\n",
      "    oversampling_factor      = 4\n",
      "    sampling_clock_frequency = 40000820.15991211\n",
      "    downsample               = 1\n",
      "    capture_group            = glitch\n",
      "    capture_depth            = 512\n",
      "trace = \n",
      "    present      = True\n",
      "    enabled      = False\n",
      "    errors       = False\n",
      "    trace_synced = False\n",
      "    trace_mode   = parallel\n",
      "    trace_width  = 4\n",
      "    clock = \n",
      "        fe_clock_alive   = True\n",
      "        fe_clock_src     = usb_clock\n",
      "        clkgen_enabled   = True\n",
      "        fe_freq          = 96000000.0\n",
      "        swo_clock_locked = True\n",
      "        swo_clock_freq   = 40000820.15991211\n",
      "    capture = \n",
      "        trigger_source         = firmware trigger\n",
      "        use_husky_arm          = False\n",
      "        raw                    = True\n",
      "        rules_enabled          = []\n",
      "        rules                  = []\n",
      "        mode                   = count_cycles\n",
      "        count                  = 0\n",
      "        max_triggers           = 1\n",
      "        triggers_generated     = 1\n",
      "        record_syncs           = False\n",
      "        matched_pattern_data   = 0000000000000000\n",
      "        matched_pattern_counts = [0, 0, 0, 0, 0, 0, 0, 0]\n",
      "XADC = \n",
      "    status                               = good\n",
      "    current temperature [C]              = 55.6\n",
      "    maximum temperature [C]              = 59.1\n",
      "    user temperature alarm trigger [C]   = 80.0\n",
      "    user temperature reset trigger [C]   = 59.9\n",
      "    device temperature alarm trigger [C] = 89.9\n",
      "    device temperature reset trigger [C] = 59.9\n",
      "    vccint                               = 0.997\n",
      "    vccaux                               = 1.791\n",
      "    vccbram                              = 0.987\n",
      "userio = \n",
      "    mode       = normal\n",
      "    direction  = 0\n",
      "    drive_data = 0\n",
      "    status     = 511\n",
      "LEDs = \n",
      "    setting = 0 (default, as labelled)\n",
      "errors = \n",
      "    sam_errors      = False\n",
      "    sam_led_setting = Default\n",
      "    XADC errors     = False\n",
      "    ADC errors      = False\n",
      "    extclk error    = False\n",
      "    trace errors    = False\n",
      ".SAD\n",
      "E    +  and   10 = state                    = False\n",
      "basic_mode               = rising_edge\n",
      "timeout                  = 3\n",
      "offset                   = 0\n",
      "presamples               = 137\n",
      "samples                  = 255\n",
      "decimate                 = 1\n",
      "trig_count               = 24\n",
      "stream_mode              = False\n",
      "test_mode                = False\n",
      "bits_per_sample          = 8\n",
      "segments                 = 10\n",
      "segment_cycles           = 32500\n",
      "segment_cycle_counter_en = False\n",
      "clip_errors_disabled     = False\n",
      "lo_gain_errors_disabled  = True\n",
      "errors                   = False\n",
      ".segments\n",
      "E    +    where state                    = False\n",
      "basic_mode               = rising_edge\n",
      "timeout                  = 3\n",
      "offset                   = 0\n",
      "presamples               = 137\n",
      "samples                  = 255\n",
      "decimate                 = 1\n",
      "trig_count               = 24\n",
      "stream_mode              = False\n",
      "test_mode                = False\n",
      "bits_per_sample          = 8\n",
      "segments                 = 10\n",
      "segment_cycles           = 32500\n",
      "segment_cycle_counter_en = False\n",
      "clip_errors_disabled     = False\n",
      "lo_gain_errors_disabled  = True\n",
      "errors                   = False\n",
      " = cwhusky Device\n",
      "sn             = 50203120374a38503230343136303038\n",
      "fpga_buildtime = 4/5/2023, 21:22\n",
      "fw_version = \n",
      "    major = 1\n",
      "    minor = 5\n",
      "    debug = 0\n",
      "gain = \n",
      "    mode = low\n",
      "    gain = 59\n",
      "    db   = 12.064220183486238\n",
      "adc = \n",
      "    state                    = False\n",
      "    basic_mode               = rising_edge\n",
      "    timeout                  = 3\n",
      "    offset                   = 0\n",
      "    presamples               = 137\n",
      "    samples                  = 255\n",
      "    decimate                 = 1\n",
      "    trig_count               = 24\n",
      "    stream_mode              = False\n",
      "    test_mode                = False\n",
      "    bits_per_sample          = 8\n",
      "    segments                 = 10\n",
      "    segment_cycles           = 32500\n",
      "    segment_cycle_counter_en = False\n",
      "    clip_errors_disabled     = False\n",
      "    lo_gain_errors_disabled  = True\n",
      "    errors                   = False\n",
      "clock = \n",
      "    clkgen_src             = system\n",
      "    clkgen_freq            = 10000000.0\n",
      "    adc_mul                = 20\n",
      "    adc_freq               = 200000000.0\n",
      "    freq_ctr               = 57\n",
      "    freq_ctr_src           = extclk\n",
      "    clkgen_locked          = True\n",
      "    adc_phase              = 0\n",
      "    extclk_monitor_enabled = False\n",
      "    extclk_error           = False\n",
      "    extclk_tolerance       = 102.996826171875\n",
      "trigger = \n",
      "    module = SAD\n",
      "io = \n",
      "    tio1            = serial_rx\n",
      "    tio2            = serial_tx\n",
      "    tio3            = high_z\n",
      "    tio4            = high_z\n",
      "    pdid            = high_z\n",
      "    pdic            = high_z\n",
      "    nrst            = high_z\n",
      "    glitch_hp       = False\n",
      "    glitch_lp       = False\n",
      "    extclk_src      = hs1\n",
      "    hs2             = clkgen\n",
      "    target_pwr      = True\n",
      "    tio_states      = (1, 1, 1, 0)\n",
      "    cdc_settings    = bytearray(b'\\x00\\x00\\x00\\x00')\n",
      "    aux_io_mcx      = high_z\n",
      "    glitch_trig_mcx = trigger\n",
      "glitch = \n",
      "    enabled           = False\n",
      "    mmcm_locked       = False\n",
      "    num_glitches      = 1\n",
      "    clk_src           = pll\n",
      "    width             = 328\n",
      "    offset            = 400\n",
      "    trigger_src       = manual\n",
      "    arm_timing        = after_scope\n",
      "    ext_offset        = 0\n",
      "    repeat            = 1\n",
      "    output            = glitch_only\n",
      "    phase_shift_steps = 3360\n",
      "ADS4128 = \n",
      "    mode      = normal\n",
      "    low_speed = True\n",
      "    hi_perf   = 2\n",
      "LA = \n",
      "    present                  = True\n",
      "    enabled                  = False\n",
      "    clkgen_enabled           = True\n",
      "    locked                   = True\n",
      "    clk_source               = pll\n",
      "    trigger_source           = glitch_trigger\n",
      "    oversampling_factor      = 4\n",
      "    sampling_clock_frequency = 40000808.71582031\n",
      "    downsample               = 1\n",
      "    capture_group            = glitch\n",
      "    capture_depth            = 512\n",
      "trace = \n",
      "    present      = True\n",
      "    enabled      = False\n",
      "    errors       = False\n",
      "    trace_synced = False\n",
      "    trace_mode   = parallel\n",
      "    trace_width  = 4\n",
      "    clock = \n",
      "        fe_clock_alive   = True\n",
      "        fe_clock_src     = usb_clock\n",
      "        clkgen_enabled   = True\n",
      "        fe_freq          = 96000000.0\n",
      "        swo_clock_locked = True\n",
      "        swo_clock_freq   = 40000820.15991211\n",
      "    capture = \n",
      "        trigger_source         = firmware trigger\n",
      "        use_husky_arm          = False\n",
      "        raw                    = True\n",
      "        rules_enabled          = []\n",
      "        rules                  = []\n",
      "        mode                   = count_cycles\n",
      "        count                  = 0\n",
      "        max_triggers           = 1\n",
      "        triggers_generated     = 1\n",
      "        record_syncs           = False\n",
      "        matched_pattern_data   = 0000000000000000\n",
      "        matched_pattern_counts = [0, 0, 0, 0, 0, 0, 0, 0]\n",
      "XADC = \n",
      "    status                               = good\n",
      "    current temperature [C]              = 55.7\n",
      "    maximum temperature [C]              = 59.1\n",
      "    user temperature alarm trigger [C]   = 80.0\n",
      "    user temperature reset trigger [C]   = 59.9\n",
      "    device temperature alarm trigger [C] = 89.9\n",
      "    device temperature reset trigger [C] = 59.9\n",
      "    vccint                               = 0.992\n",
      "    vccaux                               = 1.792\n",
      "    vccbram                              = 0.991\n",
      "userio = \n",
      "    mode       = normal\n",
      "    direction  = 0\n",
      "    drive_data = 0\n",
      "    status     = 511\n",
      "LEDs = \n",
      "    setting = 0 (default, as labelled)\n",
      "errors = \n",
      "    sam_errors      = False\n",
      "    sam_led_setting = Default\n",
      "    XADC errors     = False\n",
      "    ADC errors      = False\n",
      "    extclk error    = False\n",
      "    trace errors    = False\n",
      ".adc\n",
      "=========================== short test summary info ===========================\n",
      "SKIPPED [12] ..\\..\\tests\\test_husky.py:525: use --fulltest to run\n",
      "SKIPPED [6] ..\\..\\tests\\test_husky.py:583: use --fulltest to run\n",
      "SKIPPED [4] ..\\..\\tests\\test_husky.py:707: use --fulltest to run\n",
      "SKIPPED [3] ..\\..\\tests\\test_husky.py:769: use --fulltest to run\n",
      "SKIPPED [4] ..\\..\\tests\\test_husky.py:826: use --fulltest to run\n",
      "SKIPPED [14] ..\\..\\tests\\test_husky.py:870: use --fulltest to run\n",
      "SKIPPED [6] ..\\..\\tests\\test_husky.py:932: use --fulltest to run\n",
      "SKIPPED [8] ..\\..\\tests\\test_husky.py:975: use --fulltest to run\n",
      "SKIPPED [6] ..\\..\\tests\\test_husky.py:1049: use --fulltest to run\n",
      "SKIPPED [4] ..\\..\\tests\\test_husky.py:1230: use --fulltest to run\n",
      "SKIPPED [3] ..\\..\\tests\\test_husky.py:1404: use --fulltest to run\n",
      "SKIPPED [3] ..\\..\\tests\\test_husky.py:1443: use --fulltest to run\n",
      "SKIPPED [1] ..\\..\\tests\\test_husky.py:1503: use --fulltest to run\n",
      "SKIPPED [1] ..\\..\\tests\\test_husky.py:1537: use --fulltest to run\n",
      "SKIPPED [4] ..\\..\\tests\\test_husky.py:1674: use --fulltest to run\n",
      "====== 1 failed, 60 passed, 79 skipped, 6 deselected in 71.58s (0:01:11) ======\n",
      "\n"
     ]
    }
   ],
   "source": [
    "print(result.stdout.decode().replace(r\"\\n\", \"\\n\"))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "id": "c7c5a01f",
   "metadata": {},
   "outputs": [
    {
     "ename": "AssertionError",
     "evalue": "",
     "output_type": "error",
     "traceback": [
      "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
      "\u001b[1;31mAssertionError\u001b[0m                            Traceback (most recent call last)",
      "Input \u001b[1;32mIn [5]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[1;34m()\u001b[0m\n\u001b[1;32m----> 1\u001b[0m \u001b[38;5;28;01massert\u001b[39;00m result\u001b[38;5;241m.\u001b[39mreturncode \u001b[38;5;241m==\u001b[39m \u001b[38;5;241m0\u001b[39m\n",
      "\u001b[1;31mAssertionError\u001b[0m: "
     ]
    }
   ],
   "source": [
    "assert result.returncode == 0"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6f10e727",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
